<div [@routerTransition]>
    <div class="content d-flex flex-column flex-column-fluid">

        <sub-header [title]="'SalesInfo' | localize" [description]="'DashboardHeaderInfo' | localize">
            <div role="actions">
            </div>
        </sub-header>

        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <tabset class="tab-container tabbable-line">
                        <tab class="pt-5" heading="{{l('SkuMsg')}}" *ngIf="isGranted('Pages.Tenant.Dashboard.SalesInformation.Sku')"
                            customClass="m-tabs__item icon-dingdan1" class="pt-5" active="true">
                            <div class="row">
                                <form class="horizontal-form" autocomplete="off">
                                    <div class="m-form m-form--label-align-right">
                                        <div class="row align-items-center mb-4">
                                            <div class="col-4">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label>{{l('name')}}</label>
                                                    <div class="input-group">
                                                        <input [(ngModel)]="filterText" name="filterText" autoFocus
                                                            class="form-control m-input" (keyup.enter)="getSalesInfo()"
                                                            [placeholder]="l('SearchWithThreeDot')" type="text">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-3" style="position:relative;">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label>{{l('startEndTime')}}</label>
                                                    <date-range-picker needInitDate="true" name="SampleDateRangePicker"
                                                        [showButton]="false" [(startDate)]="startTime"
                                                        [(endDate)]="endTime" [allowFutureDate]="false">
                                                    </date-range-picker>
                                                </div>
                                            </div>
                                            <div class="col-2">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label>&nbsp;</label>
                                                    <div class="input-group">
                                                        <button type="button" class="btn btn-primary"
                                                            [buttonBusy]="primengTableHelper.isLoading"
                                                            (click)="getSalesInfo()">
                                                            <i class="la la-refresh"></i>
                                                            {{l("search")}}
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-2 text-right">
                                                <div class="form-group m-form__group align-items-center">
                                                    <label style="display:block;">&nbsp;</label>
                                                    <button type="button" class="btn btn-primary" (click)="goExport()"
                                                        [buttonBusy]="exportLoading">
                                                        <i class="icon-excel"></i>
                                                        {{l('export')}}</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="row align-items-center">
                                <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                                    <p-table #dataTable (onLazyLoad)="getSalesInfo($event)"
                                        [value]="primengTableHelper.records"
                                        [rows]="primengTableHelper.defaultRecordsCountPerPage" [paginator]="false"
                                        [lazy]="false" [resizableColumns]="primengTableHelper.resizableColumns"
                                        [responsive]="primengTableHelper.isResponsive" ScrollWidth="100%">
                                        <ng-template pTemplate="header">
                                            <tr>
                                                <th style="width: 15%">{{l('Actions')}}</th>
                                                <th style="width:5%">{{l('RecordId')}}</th>
                                                <th>SkuId</th>
                                                <th>{{l('name')}}</th>
                                                <!-- <th>{{l('Image')}}</th> -->
                                                <th pSortableColumn="number">
                                                    {{l('amount')}}
                                                    <p-sortIcon field="number"></p-sortIcon>
                                                </th>
                                                <th pSortableColumn="saleAmout">
                                                    {{l('TotalSales')}}
                                                    <p-sortIcon field="saleAmout"></p-sortIcon>
                                                </th>
                                            </tr>
                                        </ng-template>
                                        <ng-template pTemplate="body" let-record let-i="rowIndex">
                                            <tr [pSelectableRow]="record" [attr.trid]="record.id">
                                                <td>
                                                    <div class="btn-group dropdown" normalizePosition>
                                                        <button class="btn btn-sm btn-primary"
                                                            (click)="showDetail(record)">
                                                            {{l("detail")}}
                                                        </button>
                                                    </div>
                                                </td>
                                                <td style="width:5%"> {{transIndex(i)}}</td>
                                                <td>
                                                    <span>{{record.skuId}}</span>
                                                </td>
                                                <td>
                                                    <span>{{record.title}}</span>
                                                </td>
                                                <!-- <td>
                                                <img [src]="fixFileUrl(record.picUrl)" (error)="showEmpty($event)"/>
                                            </td> -->
                                                <td>
                                                    <span>{{record.number}}</span>
                                                </td>
                                                <td>
                                                    <!-- <span>{{record.saleAmout | number:'1.2-2'|currency:'￥'}}</span> -->
                                                    <span>{{record.saleAmout|currency:'￥'}}</span>
                                                </td>
                                            </tr>
                                        </ng-template>
                                        <ng-template pTemplate="emptymessage" let-records>
                                            <tr *ngIf="primengTableHelper.records">
                                                <td colspan="6">
                                                    <img class="emptymessage"
                                                        src="/assets/common/images/placeholder/deviceHolder.png" />
                                                </td>
                                            </tr>
                                        </ng-template>
                                    </p-table>
                                    <div class="primeng-paging-container">
                                        <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                            (onPageChange)="getSalesInfo($event)"
                                            [totalRecords]="primengTableHelper.totalRecordsCount"
                                            [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                                        </p-paginator>
                                        <span class="total-records-count">
                                            {{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
                                            <span style="margin-left:20px;">
                                                {{l('totalFees')}} : {{totalSale|currency:'￥'}}
                                            </span>
                                        </span>
                                    </div>
                                </div>
                                <!--<Primeng-Datatable-End>-->
                            </div>
                        </tab>
                        <tab class="pt-5" heading="{{l('MemberMsg')}}"
                            *ngIf="isGranted('Pages.Tenant.Dashboard.SalesInformation.Member')"
                            customClass="m-tabs__item icon-huiyuanguanli" (selectTab)="changePage()">
                        </tab>
                    </tabset>
                </div>
            </div>
        </div>


        <salesInfoModal #SalesInfoModalComponent></salesInfoModal>
    </div>

</div>